EXEC_ALLOWED = False

incidents = []

def secure_exec(func):
    def wrapper(code, globals=globals(), locals=locals(), *args, **kwargs):
        if EXEC_ALLOWED: return func(code, globals, locals) # После прохождения обработки и условий, возвращаем объект файла
        else:
            print("Custom code execution is not allowed. Incident will be reported.")
            incidents.append(
                [code, globals, locals]
            )

    return wrapper

exec = secure_exec(exec)
execfile = secure_exec(execfile)
